<%@ page import="com.onlinevideo.entity.User" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
	HttpSession session1 = request.getSession();
	User user =(User) session1.getAttribute("user");

	/*if(user != null ){
		if(user.getRoleId()==0){
			response.sendRedirect("../view/bgIndex.jsp");
		}else {
			response.sendRedirect("../view/mine.jsp");
		}
	}*/
%>
<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<link rel="stylesheet" type="text/css" href="../static/fonts/iconfont.css"/>
		<link rel="stylesheet" type="text/css" href="../static/css/public.css"/>
		<link rel="stylesheet" type="text/css" href="../static/css/logo.css"/>
		<script src="../static/js/jquery-1.11.3.min.js" type="text/javascript"></script>
		<script src="../static/js/sweetalert.min-2.1.2.js" type="text/javascript"></script>
		<script src="../static/js/jquery.cookies.js" type="text/javascript"></script>
		<script type="text/javascript">
			$(function (){
				$("body").parent().css("overflow-y","hidden");

				$("#loginBtn1").click(function (event){
					event.preventDefault();
					var username = $("#username").val().trim();
					if(username.length<=0){
						swal("提示","请输入用户名", "error").then(function (isOk){});
						return;
					}
					var password = $("#password").val().trim();
					if(password.length<6){
						swal("提示","密码长度必须大于六位", "error").then(function (isOk){});
						return;
					}
					var emailEndWith = $("#emailType option:selected").val().trim();
					$.ajax({
						url:"../user.do?action=login",
						data: {
							username:username+emailEndWith,
							password:password
						},
						dataType:"text",
						success:function(data){
							console.log(data)
							var result = JSON.parse(data)
							if(result.code == "1"){
								//4.向用户响应数据（成功，失败）
								swal("提示",result.message, "success").then(function (isOk){
									location.href=result.data;
								});
							}else{
								swal("警告",result.message , "error").then(function (isOk){
									//console.log(result.data)
									location.href=result.data;
								});
							}

						},
						error:function(data){
							console.log(data);
						}
					})
				});
				$("#wxlogin").click(function (){
					var s = swal({
						title:"微信扫码登录",
						buttons: {
							cancel: "取消",
							confirm: "确认",
						},
						content: {
							element: "img",
							attributes: {
								src:"../file.do?action=getQrServlet",
								style:"width:300px;height:300px"
							},
						} ,
						timer: 30000,
					}).then(function (isOk){
						swal({
							title:"验证码失效",
							buttons: {
								cancel: "取消",
								confirm: "确认",
							},
							content: {
								element: "img",
								attributes: {
									src:"../uploadFile/images/qrCodeInvalid.png",
									style:"width:300px;height:300px"
								},
							} ,
							timer: 60000,
						}).then(function (isOk){
						});
					});
				});
			});
		</script>
		<style type="text/css">

		</style>
	</head>
	<body>
	<jsp:include page="header.jsp"/>
	<div class="head">
			<div class="banner">
				<div><img src="../uploadFile/images/26.png"></div>
				<div><img src="../uploadFile/images/27.png"></div>
				<div><img src="../uploadFile/images/28.png"></div>
			</div>
		</div>
		<div class="bg"></div>
		<div class="logobox">
			<h1 id="dx">登录</h1>
			<form action="#" method="post">
				<div class="logolable"><lable>邮箱</lable></div>
				<div class="logoinput">
					<div style="width:calc(68% - 20px)"><input type="text" id="username" style="border:0px solid white"></div>
					<div style="width:25%;padding-left:0px;padding-right:20px">
						<select style="border:0px solid white" id="emailType">
							<option>@qq.com</option>
							<option>@163.com</option>
						</select>
					</div>
				</div>
				<div class="logolable"><lable>密码</lable></div>
				<div class="logomima"><input type="text" id="password"/></div>
				<div class="logobutton" id="loginBtn1"><button type="button" id="loginBtn" style="background-color: #42D333;border: 0" >登录</button></div>
			</form>
			<div class="logocaozuo">
				<div><a href="../view/register.jsp">新用户注册</a></div>
				<div><a href="#">忘记密码？</a></div>
			</div>
			<div class="logohuozhe">
				<div>或者</div>
			</div>
			<ul class="logoqita">
				<li><a href="#" id="wxlogin"><i class="iconfont icon-weixin"></i></a></li>
				<li><a href="#"><i class="iconfont icon-weibo"></i></a></li>
				<li><a href="#"><i class="iconfont icon-ai-qq"></i></a></li>
			</ul>
		</div>

	</body>
</html>
